package sanrenxing.dayEnd.backRepertoryTotal.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Valuation;

import java.util.List;

public interface ValuationDao {

    /**
     * 计算出证券库存中的估值增值
     * @return
     */
    @Select("select sysdate as businDate,ss.caId as caId,ss.seId as seId,'估值增值' as businType," +
            "1 as capflow,((ss.secNum*md.closePrice)-ss.sumMoney) as money,ss.fundId,0 as states from " +
            "securitiesStock ss join marketData md on ss.seId=md.seId")
    public List<Valuation> queryValua();

    /**
     * 将估值增值的数据添加到证券应收应付
     */
    @Insert("insert into receivableAndPayable values(seqReceivableAndPayable.nextval,to_date('${businDate}','yyyy-MM-dd'),#{caId},#{seId},#{businType},#{capflow},#{money},#{fundId},#{states})")
    public void addValuation(Valuation valuation);

    /**
     * 删除证券应收应付库存的估值增值
     */
    @Delete("delete from secRecAndPayStock where businType='估值增值'")
    public void delete();


}
